/**
 * name of package solar system is in
 */
package Model;

import java.io.Serializable;
import java.util.Random;
/**
 * Solar system class to hold planets that player will
 *  visit as he traverses the universe.
 * @author Ben
 * @version 1
 */
public class SolarSystem implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7401001118051770763L;

	/**
	 * random generator
	 */
	private final Random generator = new Random();
	
	/**
	 * int to represent techlvl
	 */
	private final int techlvl;
	
	/**
	 * name of solarsystem
	 */
	private final String solarName;
	
	/**
	 * planet array in solar system
	 */
	private final Planet[] planets = new Planet[3];
	
	/**
	 * width of universe
	 */
	public static int Width = 150;
	
	/**
	 * height of universe
	 */
	public static int Height = 150;
	
	/**
	 * boolean placement on solarsystem for in range
	 */
	private boolean inRange = false;
	
	/**
	 * This is the Constructor for solar system class. It creates
	 *  three planets within the solar system 
	 * and randomly generates their attributes.
	 * @param techlvl the tech level inputed to set the solar system at
	 * @param solarName the name of the solar system class
	 */
	public SolarSystem (int techlvl, String solarName){
		this.techlvl = techlvl;
		this.solarName = solarName;
		planets[0] = new Planet(generator.nextInt(17) + 1,
				techlvl, generator.nextInt(6) + 1);
		planets[1] = new Planet(generator.nextInt(17) + 1, 
				techlvl, generator.nextInt(6) + 1);
		planets[2] = new Planet(generator.nextInt(17) + 1,
				techlvl, generator.nextInt(6) + 1);
	}
	
	/**
	 * Returns the Solar System name.
	 * @return a string of the solar system name
	 */
	public String getSolarName(){
		return solarName;
	}
	
	/**
	 * Returns the tech level of a solar system.
	 * @return the tech level of the system
	 */
	public int getTechlvl(){
		return techlvl;
	}
	
	/**
	 * Prints whether or not the solar system names exists.
	 * @return the toString of a solar system name boolean
	 */
	public String toString() {
		if (solarName != null) {
			return "1";
		} else {
			return "0";
		}
	}
	
	/**
	 * Sets whether the solar system is in range. The GUI will reflect this in what 
	 * solar systems are available to the player.
	 * @param yo true if the solar system is in range, false if is not
	 */
	public void setInRange(boolean yo){
		inRange = yo;
	}
	
	/**
	 * Returns whether the solar system is in range. The
	 *  GUI will reflect solar systems in range.
	 * @return true if is in range, false if it is not
	 */
	public boolean getInRange(){
		return inRange;
	}
	
	/**
	 * Should return the main planet from this solar system.
	 * 
	 * @return the 0th planet from planets
	 */
	public Planet getCurrentPlanet(){
		return planets[0];
	}//end method getCurrentPlanet
}